import Vue from "vue";
import Vuex from "vuex";
import axios from 'axios'

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    count:10,
    banners:[],
    list:[]
  },
  getters:{
    countx10:(state)=> state.count *10
     
    
  },
  mutations: {
    countadd:(state)=>state.count++,

    setbanners(state,data){
      state.banners = data
    },
    setlist(state,data){
      state.list = data
    }
    
  },
  actions: {
    getbanners(context){
      axios({
        url:'https://gank.io/api/v2/banners'
    }).then(res=>{
      context.commit('setbanners',res.data.data)
      // console.log(res)
        // this.banners = res.data.data
    })
    },
    getlist({commit}){
      axios({
        url:'https://gank.io/api/v2/data/category/All/type/All/page/1/count/12'
    }).then(res=>{
      commit('setlist',res.data.data)
        // this.list = res.data.data 
    })
    }
  },
  modules: {},
});
